
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Tathata.Common.BLL.Entities;
using Tathata.Common.BLL.Managers;
using System.Collections.Generic;
using Tathata.Web;
using Tathata.Common.BLL.EntityCollections;
namespace Tathata.Web.Administration.Modules
{
    public partial class SelectDiscountsControl : BaseNopAdministrationUserControl
    {
        protected List<int> selectedDiscountIDs = new List<int>();

        public void BindData()
        {
            DiscountCollection discountCollection = DiscountManager.GetAllDiscounts();
            foreach (Discount discount in discountCollection)
            {
                ListItem item = new ListItem(discount.Name, discount.DiscountID.ToString());
                if (this.selectedDiscountIDs.Contains(discount.DiscountID))
                    item.Selected = true;
                this.cblDiscounts.Items.Add(item);
            }
            this.cblDiscounts.DataBind();
        }
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        public string CssClass
        {
            get
            {
                return cblDiscounts.CssClass;
            }
            set
            {
                cblDiscounts.CssClass = value;
            }
        }

        public List<int> SelectedDiscountIDs
        {
            get
            {
                List<int> result = new List<int>();
                foreach (ListItem item in this.cblDiscounts.Items)
                    if (item.Selected)
                        result.Add(int.Parse(item.Value));
                return result;
            }
            set
            {
                this.selectedDiscountIDs = value;
            }
        }
    }
}